
const commonConfig = require('./webpack.common.js')
const { merge } = require('webpack-merge')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const CopyPlugin = require('copy-webpack-plugin')
const webpack = require('webpack')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')

module.exports = merge(commonConfig,{
    mode: 'production',
    plugins: [
        new CleanWebpackPlugin(),
        new VueLoaderPlugin(),
        new webpack.DefinePlugin({
            BASE_URL: '"./"',
        }),
        new HtmlWebpackPlugin({
            title: 'my webpack demo',
            template: './public/index.html',
            filename: 'index.[contenthash:8].html',
        }),
        new CopyPlugin({
            patterns: [
                {
                    from: "public", filter: async resourcePath => {
                        return !/\.html$/.test(resourcePath)
                    }
                },
            ],
        }),
    ]
})